﻿using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Net.Http.Headers;

namespace MyWeb.Areas.Define.Controllers
{
    public class ErrorController : Controller
    {
        private readonly IHostingEnvironment _env;

        public ErrorController(IHostingEnvironment env)
        {
            _env = env;
        }

        [Route("error/{code}")]
        public IActionResult Index(int code)
        {
            string path = $"{_env.WebRootPath}/html/error/{code}.html";
            return new PhysicalFileResult(path, new MediaTypeHeaderValue("text/html"));
        }
    }
}